package com.sxt.websocket.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;


@Configuration
@EnableWebSocketMessageBroker
@EnableScheduling
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
	
		@Override
	    public void registerStompEndpoints(StompEndpointRegistry registry) {
			  //注册一个STOMP的endpoint,并指定使用SockJS协议
	        registry.addEndpoint("/endpointOyzc").setAllowedOrigins("*").withSockJS();

	    }
	    @Override
	    public void configureMessageBroker(MessageBrokerRegistry registry) {
	        registry.enableSimpleBroker("/topic","/queue");//设置服务器广播消息的基础路径,可以是多个路径
	        registry.setApplicationDestinationPrefixes("/app");//设置客户端订阅消息基础路径
	        registry.setUserDestinationPrefix("/queue");//设置精准消息推送基础路径
	    }
	}

